@extends('../manage.layout')
@section('content')
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            首页轮播图
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
            <li class="active">Here</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <!-- general form elements -->
                <div class="box-body table-responsive no-padding">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            {{--<h3 class="box-title">文章添加</h3>--}}
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <form method="post" action="{{ url('manage/config/setSlide') }}" enctype="multipart/form-data">
                            {{ csrf_field() }}
                            {{--<input type="hidden" name="_token" value="{{ csrf_token() }}">--}}
                            <input id="id" type="hidden" name="id" value="">
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="title">选择轮播</label>
                                    <select id="getValue" class="form-control" name="param" onchange="getPicture()">
                                        <option value="1" @if($a == 1)selected="selected"@endif>图1(pc)</option>
                                        <option value="2" @if($a == 2)selected="selected"@endif>图2(pc)</option>
                                        <option value="3" @if($a == 3)selected="selected"@endif>图3(pc)</option>
                                        <option value="4" @if($a == 4)selected="selected"@endif>图4(pc)</option>
                                        <option value="5" @if($a == 5)selected="selected"@endif>图5(pc)</option>
                                        <option value="6" @if($a == 6)selected="selected"@endif>图6(pc)</option>
                                        <option value="7" @if($a == 7)selected="selected"@endif>图7(pc)</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="name">权重</label>
                                    <input class="form-control" placeholder="权重" type="number" min="0" id="rank" name="rank" value="">
                                </div>
                                <div class="form-group">
                                    <label for="name">轮播图（pc:1010px*600px）</label>
                                    <input type="file" id="file" name="picture"><br>
                                    <img id="picture" width="500" src="" />
                                </div>
                                <div class="form-group">
                                    <label for="name">链接地址(不带域名)</label>
                                    <input id="url" class="form-control" placeholder="请输入链接地址" name="url" value=""/>
                                </div>

                            </div>
                            <!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">确定</button>&nbsp;&nbsp;<span class="btn btn-primary" onclick="window.location.href='/manage/article'">返回</span>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- /.content -->
@endsection
@section('script')
    <script>
        $(function(){
            ajax('{{$a}}');
        });
        function getPicture(){
            var a = $('#getValue').val();
            ajax(a);
        }
        function ajax(a){
            $.ajax({
                url:'/manage/config/getSlide' ,
                data:{a:a},
                type:'get',
                async:false,
                success:function(res){
                    console.log(res);
                    if(res.code == 100){
                        $('#picture').attr('src',res.res.picture);
                        $('#url').val(res.res.url);
                        $('#id').val(res.res.id);
                        $('#rank').val(res.res.rank);
                    }else{
                        alert(res.msg);
                    }

                },
                error:function(){
                    alert('error');
                }
            });
        }
    </script>
@endsection

